#include <stdio.h>
#include <stdlib.h>

typedef int ElemType;

typedef struct
{
    ElemType *elem; //动态数组基地址
    int TableLen;//表长度
} SSTable;

// 顺序查找
int Search_Seq(SSTable ST, ElemType key)
{
    int i;
    for (i = 0; i < ST.TableLen && ST.elem[i] != key; i++)
        ;
    // 查找成功,返回元素下标,失败,返回-1
    return i == ST.TableLen ? -1 : i;
}

int main()
{

    ElemType data[] = {1, 22, 3, 4, 6, 7};
    int len = sizeof(data) / sizeof(ElemType);

    SSTable ST = {data, len};
    ElemType key = 3;

    int index = Search_Seq(ST, key);

    // 输出结果
    if (index != -1)
    {
        printf("Element %d found at index %d\n", key, index);
    }
    else
    {
        printf("Element %d not found\n", key);
    }

    return 0;
}